import {reqSearch} from '../../api/searchresult'
Page({
    data: {
      
        // 页面数据
      goods: [],
      type:''
        
      },
      navigateToSearchPage: function() {
        const type = this.data.type
        if(type){
          wx.navigateTo({
            url: `/pages/search/search?type=${type}`, // 替换为你的搜索页面路径
          })
        }else{
          wx.navigateTo({
            url: '/pages/search/search',
          })
        }
      },

      onLoad: function(options) {
        const record = options.record; 
        const type = options.type;
        if (record) {
          this.setData({
            record:record
          })
        }
        if(type) {
          this.setData({
            type:type
          })
        }

        this.search()
      },

      async search(){
        const config={
          'content-type': 'application/x-www-form-urlencoded'
        }
    
        const param = {
          record:this.data.record
        }
    
        const {data} = await reqSearch(param,config)
        this.setData({
          goods:data
        })
      },

      navigateToGoodDetail:function(e){
        const id = e.currentTarget.dataset.productid
        const type = this.data.type
        const businessType = 3
        // console.log(e.currentTarget.dataset.productid)
        wx.navigateTo({
          url: `/pages/good/good?productId=${id}&type=${type}&businessType=${businessType}`,
        })
      }


    
    
})